<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

		<script type="text/javascript">
			$(function() {

				$("#b1").click(function() {

					//ajax请求 ,data 从servlet中响应的结果 ""
					//
					$.get("ajax.do", function(data, status) {
						//console.log(data + "," + status);
						//$("#divUsers").html(data);
						
						//将data转换为json格式的"对象""
						var arr = JSON.parse(data);
						//才能用$.each
						$.each(arr, function(index,user) {
							console.log(user.userId+","+user.userName);
							$("#divUsers").append("<p>"+user.userId+","+user.userName+"</p>");
						});
					});
					
					

				});

				

			});
		</script>
	</head>

	<body>
		<input type="button" id="b1" value="ajax请求" />
        <div id="divUsers"></div>
		
	</body>

</html>